<template>
  <div class="talkinternet-box">
    <div class="wrap">
      <ul>
        <li class="list" v-for="(item, index) in userList" :key="index">
          <div class="list-header">
            <img :src="item.head_pic" alt="" class="img1" />
            <div class="user">
              <p class="title">{{ item.title }}</p>
              <p class="writer">{{ item.writer }}</p>
              <div class="logo">{{ item.label }}</div>
            </div>
            <img :src="music" alt="" class="img2" />
          </div>
          <img :src="item.img" alt="" class="list-img" />
          <p class="desc">{{ item.series }}</p>
          <div class="zan">
            <span @click="zanHandle(index)">
              <img :src="item.zan" alt="" style="width: 14px; height: 14px" />
              {{ item.like }}
            </span>
            <span>
              <img :src="item.pinglun" alt="" />
              {{ item.message }}
            </span>
          </div>
        </li>
      </ul>
      <div class="page">
        <Pages :page="100" />
      </div>
    </div>
  </div>
</template>

<script>
import Pages from "../../components/Pages";
export default {
  components: {
    Pages,
  },
  data() {
    return {
      userList: [],
      music: "http://iwenwiki.com/api/blueberrypai/indexImg/musicIcon_03.png", // 音乐
    };
  },
  methods: {
    zanHandle(index) {
      this.userList[index].isZanFalg = !this.userList[index].isZanFalg;
      if (this.userList[index].isZanFalg) {
        this.userList[index].like += 1;
        this.userList[index].zan =
          "http://iwenwiki.com/api/blueberrypai/indexImg/zan-big_03.png";
      } else {
        this.userList[index].like -= 1;
        this.userList[index].zan =
          "http://iwenwiki.com/api/blueberrypai/image/listenSpeak/gray-appl.png";
      }
    },
  },
  mounted() {
    this.$api.ListeningInfo().then((res) => {
      if (res.data.success) {
        var arr = res.data.listening;
        for (var i = 0; i < arr.length; i++) {
          arr[i].img =
            "http://iwenwiki.com/api/" + String(arr[i].img).slice(24);
          arr[i].head_pic =
            "http://iwenwiki.com/api/" + String(arr[i].img).slice(24);
          arr[i].zan =
            "http://iwenwiki.com/api/blueberrypai/image/listenSpeak/gray-appl.png";
          arr[i].pinglun =
            "http://iwenwiki.com/api/blueberrypai/image/listenSpeak/gray-wechat.png";
          arr[i].isZanFalg = false;
        }
        this.userList = arr;
      }
    });
  },
};
</script>

<style lang="less" scoped>
.talkinternet-box {
  text-align: left;
  background: #f2f2f2;
  overflow: hidden;
  padding-bottom: 20px;
}
.wrap {
  width: 1200px;
  margin: 0 auto;
}
ul {
  column-count: 4;
  column-fill: auto;
  break-inside: avoid;
  column-gap: 10px;
}
.list {
  box-sizing: border-box;
  float: left;
  margin: 20px 20px 0 0;
  background: #fff;
  width: 285px;
  break-inside: avoid;
  column-gap: 10px;
  .list-header {
    height: 79px;
    position: relative;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    .img1 {
      width: 40px;
      height: 40px;
      margin: 20px 10px;
      float: left;
    }
    .img2 {
      position: absolute;
      bottom: 15px;
      right: 20px;
    }
    .user {
      float: left;
      margin-top: 20px;
      .writer {
        color: #999;
        font-size: 12px;
      }
      .logo {
        display: inline;
        border: 1px solid rgb(0, 225, 255);
        border-radius: 30px;
        color: rgb(0, 225, 255);
        font-size: 12px;
        padding: 2px 8px;
        position: absolute;
        top: 20px;
        right: 10px;
      }
    }
  }
  .list-img {
    width: 285px;
  }
  .desc {
    padding: 20px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 14px;
  }
}
.zan {
  margin: 10px 0;
  span {
    margin-left: 10px;
    font-size: 14px;
    color: #999;
  }
}
.page {
  margin: 20px auto 0;
  text-align: center;
}
</style>